#define _CRT_SECURE_NO_WARNINGS 1

void Reveser(int left, int right, int* nums)
{
    while (left < right)
    {
        int temp = nums[left];
        nums[left] = nums[right];
        nums[right] = temp;
        left++;
        right--;
    }
}

void rotate(int* nums, int numsSize, int k) {
    k %= numsSize;
    Reveser(0, numsSize - k - 1, nums);
    Reveser(numsSize - k, numsSize - 1, nums);
    Reveser(0, numsSize - 1, nums);
}